package com.app.partner.control;

import com.app.partner.model.User;
import com.app.partner.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("/usercontroller")

public class UserController {
   @Autowired
   UserService userService;

    @RequestMapping(value="/partServlet",method= RequestMethod.POST)
    public User findAll() throws Exception{
        return userService.findAll();
    }



    @RequestMapping(value = "/insert",method= RequestMethod.POST)
    public  void insert(@Validated @RequestParam(value = "reusername",required = false) String reusername ,@RequestParam(value = "repassword",required = false) String repassword,@RequestParam(value = "reentername",required = false) String reentername,@RequestParam(value = "renumber",required = false) String renumber) throws Exception{
        User user=new User(reusername,repassword,renumber,reentername);
        userService.save(user);

    }

}
